<template>
  <div class="login-bg">
    <img :src="image" style="width: 100px;height: 20px;" @click="changeImg">
    <input type="text" v-model="code">
    <mt-button @click.native="login">登录</mt-button>

    <input type="text" v-model="mobile">
    <input type="text" v-model="province">
    <mt-button @click.native="change">修改</mt-button>
  </div>
</template>

<script>
  import {Toast} from 'Mint-ui'

  export default {
    name: 'Login',
    data () {
      return {
        code: '',
        image: '',
        mobile: '',
        province: ''
      }
    },
    methods: {
      login () {
        let params = {code: this.code}
        this.$post('/vue/llj/jinkong_login', params).then(data => {
          msg(data)
          this.changeImg()
        })
      },
      changeImg () {
        this.$post('/vue/llj/jinkong_img').then(data => {
          this.image = data
        })
      },
      change () {
        let params = {mobile: this.mobile, province: this.province}
        this.$post('/vue/llj/jinkong_position', params).then(data => {
          msg(data)
        })
      }
    },
    mounted () {
      this.changeImg()
    }
  }
  const msg = (msg) => {
    Toast({
      message: msg,
      position: 'bottom',
      duration: 2000
    })
  }
</script>

<style lang="less">
  .login-bg {
    height: 100vh;
    background-color: #FFF;
    .mint-button {
      margin: 0 12px;
      width: 90%;
    }
  }
</style>